<?php

namespace App\Http\Controllers\OpenShop\Wap;

use App\Http\Controllers\BaseController;
use App\Http\Resources\OpenShop\InvestmentPromotion\OrderDetailResource;
use App\Library\Rms\RmsPayApi;
use App\Models\OpenShop\InvestmentPromotion\OpenShopMainProcessModel;
use App\Service\OpenShop\UserContractService;
use App\Service\OpenShop\Wap\SignOrderService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;

class SignOrderController extends BaseController
{
    /**
     * 支付详情
     * @param Request $request
     * @param string $secretOrderNo
     * @return JsonResponse
     * @throws ValidationException
     */
    public function payDetail(Request $request, string $secretOrderNo): JsonResponse
    {
        // orderNo需要解密
        $orderNo = OrderDetailResource::decodeSignUrl($secretOrderNo);
        if ($request->has('debugOrderNo')) {
            $orderNo = $request->get('debugOrderNo');
        }

        return $this->success((new SignOrderService($orderNo))->getPayContractDetailByStep());
    }

    /**
     * 获取shopId
     * @param Request $request
     * @param string $orderNo
     * @return JsonResponse
     */
    public function getShop(Request $request, string $orderNo): JsonResponse
    {
        return $this->success((new SignOrderService($orderNo))->getShop());
    }
}
